package com.eliasbalasis.dwr4gwt.client;

import java.util.EventObject;

public final class DwrEvent extends EventObject {
	public final static int TYPE_NULL             =  0;
	public final static int TYPE_REMOTECALL_REPLY =  1;
	public final static int TYPE_REMOTECALL_ERROR =  2;
	public final static int TYPE_GENERAL_ERROR    =  3;
	public final static int TYPE_GENERAL_WARNING  =  4;

	private DwrRemoteMethodCallDescriptor remoteMethodCallDescriptor;
	private DwrException dwrException;
	private int type = TYPE_NULL;

	DwrEvent(IDwrAdapter source, DwrRemoteMethodCallDescriptor remoteMethodCallDescriptor) {
		super(source);
		setRemoteMethodCallDescriptor(remoteMethodCallDescriptor);
	}

	DwrEvent(IDwrAdapter source) {
		super(source);
	}

	public IDwrAdapter getSender() {
		return (IDwrAdapter)getSource();
	}

	public DwrRemoteMethodCallDescriptor getRemoteMethodCallDescriptor() {
		return remoteMethodCallDescriptor;
	}
	private void setRemoteMethodCallDescriptor(
			DwrRemoteMethodCallDescriptor remoteMethodCallDescriptor) {
		this.remoteMethodCallDescriptor = remoteMethodCallDescriptor;
	}

	public DwrException getDwrException() {
		return dwrException;
	}
	void setDwrException(DwrException error) {
		this.dwrException = dwrException;
	}

	public int getType() {
		return this.type;
	}
	void setType(int type) {
		this.type = type;
	}
}
